import datetime as dt

from backtest import BackTest
from config import test_config
import utils
# 没有注册tushare之前没办法运行


start_date, end_date = test_config['start_date'], test_config['end_date']
trade_date = utils.get_trade_date(start_date, end_date)
stocklist = utils.get_stocklist()

bt = BackTest(test_config, stocklist)


for date in trade_date:
    data = utils.get_data(date).reindex(stocklist)
    bt.update_data(data, dt.datetime.strptime(date, '%Y-%m-%d'))
    bt.trigger_strategy()